home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 January - Disc 2
/
Macworld (1999-01) (Disk 2).dmg
/
Serious Demos
/
Symbolic Composer 4.2
/
Environment
/
Projects
/
Contributed Scores
/
Peter Stone Punctus
/
Bridge
< prev
next >
Wrap
Lisp/Scheme
|
1998-10-26
|
10KB
|
273 lines
(def-orchestra 'orchestra
piano (lefthand righthand 3rd-voice)
)
(defun filter-harmonize2 (mel1 mel2 mod-val tonality n-control s-values)
(diagnostic2 "filter-harmonize" $cr$)
(setq mel1 (symbol-trim (length mel2) mel1))
(prog (out1 out2 gap swap counter n n-times n-count n-values s-master semitones
maptable)
(setq maptable (build-maptable (car tonality)))
(setq counter 0)
(setq swap t)
(setq s-master s-values)
(setq semitones (car s-master))
(setq n-values n-control)
(setq n (caar n-values))
(setq n-times (cadar n-values))
(setq n-count 0)
loop
(cond ((null mel2) (return (list (nreverse out2) (nreverse out1)))))
(cond ((= counter n)
(setq counter 0)
(setq n-count (1+ n-count))
(setq swap (not swap))))
(setq counter (1+ counter))
(cond ((= n-count n-times)
(setq s-master (cdr s-master))
(when (null s-master)
(setq s-master s-values))
(setq semitones (car s-master))
(setq n-count 0)
(setq n-values (cdr n-values))
(when (null n-values)
(setq n-values n-control))
(setq n (caar n-values))
(setq n-times (cadar n-values))))
(if swap
(cond ((or (equal (car mel1) '=) (equal (car mel2) '=))
(push (car mel1) out2)
(push (car mel2) out1))
(t (setq gap (abs (- (symbol-to-mapped-integer (car mel1) maptable)
(symbol-to-mapped-integer (car mel2) maptable))))
(cond ((member (mod gap mod-val) semitones)
(push (closest-harmony (symbol-to-mapped-integer (car mel2) maptable)
(symbol-to-mapped-integer (car mel1) maptable)
(car mel1) (car mel2))
out1)
(push (car mel1) out2))
(t (push (car mel2) out1)
(push (car mel1) out2)))))
(cond ((or (equal (car mel1) '=) (equal (car mel2) '=))
(push (car mel2) out1)
(push (car mel1) out2))
(t (setq gap (abs (- (symbol-to-mapped-integer (car mel1) maptable)
(symbol-to-mapped-integer (car mel2) maptable))))
(cond ((member (mod gap mod-val) semitones)
(push (closest-harmony (symbol-to-mapped-integer (car mel1) maptable)
(symbol-to-mapped-integer (car mel2) maptable)
(car mel2) (car mel1))
out2)
(push (car mel2) out1))
(t (push (car mel1) out2)
(push (car mel2) out1))))))
(pop mel1)
(pop mel2)
(go loop)))
(defun closest-harmony (m1 m2 s1 s2)
(if (> (get-random 0 10) 5)
'=
(integer-to-symbol (+ (symbol-to-integer s2) 3))))
(defun symbol-mod (n offset s)
(if (equal s '=)
'=
(if (< (symbol-to-integer s) n)
s
(integer-to-symbol (+ offset (mod (symbol-to-integer s) n))))))
(defun symbol-fold (n offset s)
(mapcar #'(lambda (x) (symbol-mod n offset x)) s))
; (symbol-fold 14 7 '(a b c d e f g h i j k l m n o p q r s t u v))
(defun make-tr-melody (mel repeat trpat sign)
(let ((out nil)
(master-tr trpat)
(trval nil))
(dotimes (i (length trpat))
(setq trval (car master-tr))
(setq master-tr (cdr master-tr))
(if (null master-tr) (setq master-tr trpat))
(dotimes (j repeat)
(push (symbol-transpose trval (symbol-scroll (* sign i) mel)) out)))
(flatten (nreverse out))))
(def-grammar 'progression
a (a b d)
b (-c -b a)
)
(setq seedpat1 (symbol-trim 32 (gen-trans a 4 'progression)))
(setq seedpat2 (symbol-inversion 'e seedpat1))
(setq seedpat3 (symbol-trim 32 (gen-trans b 3 'progression)))
(mapcar #'symbol-to-integer seedpat1)
(setq transpat (mapcar #'symbol-to-integer seedpat1))
(setq transpat2 (mapcar #'symbol-to-integer seedpat2))
(setq transpat3 (mapcar #'symbol-to-integer seedpat3))
(setq melody-1 (symbol-fold 14 7 (make-tr-melody seedpat1 2 transpat2 1)))
(setq melody-2 (symbol-fold 14 7 (make-tr-melody seedpat2 2 transpat2 -1)))
(setq tempo-zone-len (/ (get-ratio '12/1 :ratio)
(get-ratio '1/8 :ratio)))
(setq tempomap1 (gen-fourier
(gen-random 0.479123 5 '(1 2 3 5 8)) ; frequencies
'(0.6 0.2 (gen-sin 10 0.22 64) 0.2) ; amplitudes
'(0 45 90) ; initial phases
tempo-zone-len))
(setq tempomap2 (gen-fourier
(gen-random 0.491237 5 '(1 2 3 5 8)) ; frequencies
'(0.6 0.2 (gen-sin 10 0.22 64) 0.2) ; amplitudes
'(0 45 90) ; initial phases
tempo-zone-len))
(setq chords
(symbols-to-tonality
symbols seedpat1
transpose '((0 2 3 4 6) (0 2 3 4 6) (0 2 3 4 6) (0 2 3 4 6) (0 2 3 4 6) (0 2 3 4 6)
(0 2 4 6) (0 2 4 6) (0 2 4 6) (0 2 4 6) (0 2 4 6) (0 2 4 6))
mapping (activate-tonality (diminished2 c 3) (diminished2 c 3) (diminished2 c 3)
(diminished2 c 3) (diminished2 c 3) (diminished2 c 3)
(diminished1 g 2) (diminished1 g 2) (diminished1 g 2)
(diminished1 g 2) (diminished1 g 2) (diminished1 c 3))
)
)
(def-section intro
default ; 24 bars
zone '(1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1
1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1 1/1)
tempo-zones (symbol-repeat 24 '(1/1))
tempo (vector-to-list (vector-round 93 100 (vector-quantize 12 24 (vector-mix tempomap1 tempomap2))))
length '(1/16)
velocity '(64)
righthand
tonality (symbol-repeat 2 chords)
symbol melody-1
channel 1
length '((1/16) (1/2) (1/16) (1/2) (1/16) (1/2) (1/16) (1/2)
(1/16) (1/16) (1/8t) (1/8t)
(1/4) (1/4) (1/8t) (1/8t) (1/4) (1/4) (1/8t) (1/8t) (1/4) (1/4) (1/8t) (1/8t))
tuning (vector-to-list (vector-round -300 300 (gen-noise-white 128 1 0.39392)))
;duration (vector-to-list (vector-round (get-tick '1/9) (get-tick '1/30) tempomap1))
velocity (vector-round 70 105 tempomap1)
lefthand
tonality (symbol-repeat 2 chords)
symbol melody-2
channel 2
length '((1/2) (1/16) (1/2) (1/16) (1/2) (1/16) (1/2) (1/16)
(1/16) (1/16) (1/8t) (1/8t)
(1/8t) (1/8t) (1/4) (1/4) (1/8t) (1/8t) (1/4) (1/4) (1/8t) (1/8t) (1/8t) (1/8t))
tuning (vector-to-list (vector-round -300 300 (gen-noise-white 128 1 0.29392)))
;duration (vector-to-list (vector-round (get-tick '1/9) (get-tick '1/30) tempomap2))
velocity (vector-round 70 105 tempomap2)
3rd-voice
tonality (symbol-repeat 2 (activate-tonality (melodic-minor g 4) (major a 5) (melodic-minor d 4)))
channel 5
length '(1/16)
symbol '(=)
velocity '(0)
)
#| This is a comment
(midiport :printer)
(play-file-p nil
piano '(intro prelude)
)
|#
;;; part b
(setq seedpat1 (vector-to-symbol a h (vector-quantize 7 8 (vector-resynthesize 3 (gen-noise-white 256 1 0.121654921215454) nil t))))
(setq seedpat2 (symbol-inversion 'e seedpat1))
(setq seedpat3 (vector-to-symbol a h (vector-quantize 7 8 (vector-resynthesize 3 (gen-noise-white 256 1 0.2216549212115154) nil t))))
(mapcar #'symbol-to-integer seedpat1)
(setq transpat (mapcar #'symbol-to-integer seedpat1))
(setq transpat2 (mapcar #'symbol-to-integer seedpat2))
(setq transpat3 (mapcar #'symbol-to-integer seedpat3))
(setq theme-source
(make-tr-melody seedpat1 1 transpat 0))
(setq theme theme-source)
(setq melody-1-source
(append theme
(symbol-transpose 8
(symbol-inversion 'a theme))))
(setq melody-2-source
(symbol-transpose 11
(symbol-shift (/ (length theme) 1)
melody-1-source)))
(setq len2 (append (symbol-repeat 4 '(1/8 1/8 1/8 1/8))
(symbol-repeat 2 '(1/16 1/16 1/16 1/16))
(symbol-repeat 2 '(1/8 1/8 1/8 1/8))
(symbol-repeat 2 '(1/16 1/16 1/16 1/16))
(symbol-repeat 2 '(1/8 1/8 1/8 1/8))))
(setq len1 (append (symbol-repeat 4 '(1/8 1/8 1/8 1/8))
(symbol-repeat 2 '(1/16 1/16 1/16 1/16))
(symbol-repeat 2 '(1/8 1/8 1/8 1/8))
(symbol-repeat 2 '(1/16 1/16 1/16 1/16))
(symbol-repeat 2 '(1/8 1/8 1/8 1/8))))
(multiple-value-setq (hmel1 hmel2)
(len-harmonize2 melody-1-source len1
melody-2-source len2
12
'32/1
(activate-tonality (harmonic-minor c 2))
'((4 2))
'((1 2 3 6 8 9 10 11))))
(setq len2 (append '(-1/16) (symbol-trim 96 len2)))
(setq melody-1-mat (symbol-fold 14 7 (filter-deactivate 2 30 (find-change hmel1))))
(setq melody-2-mat (symbol-fold 14 7 (filter-deactivate 2 30 (find-change hmel2))))
(setq melody-1 melody-1-mat)
(setq melody-2 melody-2-mat)
(def-section prelude
default
zone '(32/1)
tempo-zones (symbol-trim (* 2 tempo-zone-len) '(1/8))
tempo (append (vector-to-list (vector-round 70 85 tempomap1))
(vector-to-list (vector-round 70 85 tempomap1)))
tonality (activate-tonality (harmonic-minor a 3))
lefthand
channel 3
symbol melody-1
length len1
tonality (activate-tonality (harmonic-minor a 3))
velocity (symbol-to-velocity 65 110 3 (symbol-repeat 4 theme))
tuning (vector-to-list (vector-round -200 200 (gen-noise-white 128 1 0.18152212)))
righthand
channel 4
symbol melody-2
length len2
velocity (symbol-to-velocity 65 110 3 (reverse (symbol-repeat 4 theme)))
tuning (vector-to-list (vector-round -200 200 (gen-noise-white 128 1 0.28152212)))
3rd-voice
tonality (symbol-repeat 2 (activate-tonality (melodic-minor g 4)))
channel 5
length '(1/16)
symbol '(=)
velocity '(0)
)
(play-file-p nil
piano '(intro prelude)
)